package cn.atzxc.qy.utils;

import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;

/**
 * 密码生成工具
 */
public class UtilsPasswordEncoder {


    public static void main(String[] args) {
        // 使用 BCryptPasswordEncoder 进行密码编码
        PasswordEncoder encoder = new BCryptPasswordEncoder();

        // 原始密码
        String rawPassword = "123456";

        // 对密码进行编码
        String encodedPassword = encoder.encode(rawPassword);
        System.out.println("Encoded Password: " + encodedPassword);

        // 验证密码
        boolean isPasswordMatch = encoder.matches(rawPassword,
                "$2a$10$hvs9mzWYpqrjQFJ0TTv6DeUaqve34s7JDxS7/yx5hcwnn4Na63oui");
        System.out.println("Password Match: " + isPasswordMatch);
    }

}
